package com.xhs.dto.response;

import com.xhs.entity.Comment;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 评论响应DTO
 */
@Data
public class CommentResponse {
    private Long id;
    private String text;
    private String userName;
    private Long userId;
    private Long contentId;
    private Long parentId;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    
    public static CommentResponse fromEntity(Comment comment) {
        CommentResponse response = new CommentResponse();
        response.setId(comment.getId());
        response.setText(comment.getText());
        response.setUserName(comment.getUser().getUsername());
        response.setUserId(comment.getUser().getId());
        response.setContentId(comment.getContent().getId());
        response.setParentId(comment.getParent() != null ? comment.getParent().getId() : null);
        response.setCreatedAt(comment.getCreatedAt());
        response.setUpdatedAt(comment.getUpdatedAt());
        return response;
    }
} 